<template>
  <div class="books_import">
    <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>内容管理</el-breadcrumb-item>
        <el-breadcrumb-item> 导入记录 </el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>

    <basic-container>
      
      <avue-crud
        ref="crud"
        v-if="option.column"
        :option="option"
        :data="data"
        :page.sync="page"
        v-model="form"
        :table-loading="loading"
        @on-load="getImportRecod"
        @row-save="rowSave"
        @refresh-change="refreshChange"
        @search-reset=" resetForm"
        @search-change="searchChange"
      >
       <template slot="date" slot-scope="scope" >

        </template>
       
     
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import { getImportRecod } from "@/api/cat/book";
import { catUrl,transUrl } from "@/config/env";
import { common } from "@/api/cat/httpRequest";
import {
  AppBook as baseURL,
  bookCategory,
} from "@/api/cat/baseUrls";
export default {
    data() {
    return {
      loading: false,
      page: {
        total: 0,
        pageNumber: 1,
        pageSize: 10,
      },
      size: 0,
      data: [],
      json: {},
      fileList:[],
      fileList2:[],
      url:`${catUrl}/${baseURL.toLead}`,
      url2:`${catUrl}/${baseURL.toLead2}`,
      is_open_smartSearch: false,
      form: {},
      param: {},
      condition: [],
      category: [],
       option: {
        title: "书籍列表",
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: false,
        searchBtn: true,
        refreshBtn: true,
        border: true,
        menu: false,
        column: [
        {
          label: "日期",
          fixed: "left",
          align: "center",
          prop: "createTime",
          type: "date",
          format: "yyyy-MM-dd HH:mm:ss",
          valueFormat: "yyyy-MM-dd",
          search: false,
          sortable: true,
        },
          {
            label: "英文书籍ID",
            prop: "bookIdEn",
            type: "input",
            span: "书籍id",
            gutter: "id",
            search: true,
            addDisplay: false,
            editDisplay: false,
            addDisabled: true,
            editDisabled: true,
            readonly: true,
          },
         
          {
            label: "英文书籍名称",
            prop: "bookNameEn",
            type: "input",
            search: true,
          },
          {
            label: "英文书籍作者ID",
            prop: "authorId",
            type: "input",
            search: true,
            addDisplay: false,
            editDisplay: false,
            addDisabled: false,
            editDisabled: false,
          },
          {
            label: "英文作者名称",
            prop: "authorNameEn",
            type: "input",
            search: true,
            required: true,
            span: 9,
            editDisabled: true,
          },
          {
            label: "语言类型",
            prop: "language",
            type: "select",
            editDisplay: false,
            editDisabled: true,
            search: true,
            placeholder: "语言类型",
            dicData: [
              {
                label: "英文",
                value: 2,
              },
              {
                label: "中文",
                value: 1,
              },
            ],
            props: {
              label: "label",
              value: "value",
            },
          },
          {
            label: "中文书籍ID",
            prop: "bookId",
            type: "input",
            search: true,
            addDisplay: false,
            editDisplay: false,
            addDisabled: false,
            editDisabled: false,
          },
           {
            label: "中文书籍名称",
            prop: "bookName",
            type: "input",
            search: false,
          },
          {
            label: "导入方式",
            prop: "importType",
            type: "select",
            editDisplay: false,
            editDisabled: true,
            search: true,
            placeholder: "语言类型",
            dicData: [
              {
                label: "手动上传",
                value: 1,
              },
              {
                label: "机翻",
                value: 2,
              },
            ],
            props: {
              label: "label",
              value: "value",
            },
          },
           {
            label: "最后操作信息",
            prop: "editTime",
            type: "input",
            addDisplay: false,
            editDisplay: false,
            addDisabled: true,
            editDisabled: true,
            readonly: true,
          },
          
        ],
      },
    };
  },
   async created() {
    let data = await common(`${bookCategory.getListByLeave}/1`);
    console.log(data)
    if (data.code == 1) {
      this.option.column[7].dicData = data.data;
    }
  },
  methods: {
    refreshChange() {
      this.getImportRecod();
    },
     pages(data) {
      this.page.total = data.pageCount;
      this.page.pageSize = data.pageSize;
      this.page.currentPage = data.pageNumber;
    },
    resetForm(){
      this.form = {}
      this.channel_id = ''
    },
    searchChange(params, done) {
      this.condition = [];
      console.log(this.channel_id,'this.channel_id')
      let item={channel_id:this.channel_id}
      this.params ={ ...params,...item};
      // for (let key in params) {
      //   this.condition.push({ express: key + " like '%" + params[key] + "%'" });
      // }
      this.page.pageNumber = 1;
      this.page.pageSize = 10;
      this.getImportRecod();
      if (done) done();
    },
    async rowSave(row, done) {},
    async getImportRecod() {
        this.loading = true;
        let param = Object.assign(
          {
            pageNumber: this.page.currentPage,
            pageSize: this.page.pageSize,
          },
          this.params
        );
        this.data = [];
        let list = await getImportRecod(param);
        // let list = [{"code":1,"current":1,"rows":[{"author_id":"2123","author_name_en":"zhangsan","book_id":"1","book_id_en":"E1","book_name":"书","book_name_en":"shuming","create_time":"2021-09-07 18:47:25","id":1,"import_type":1,"language":2,"update_time":"2021-09-07 18:48:19"}],"size":10,"total":1}] 
        this.pages(list.data);
        list = list.data.source;
        this.data = list;
        this.loading = false;
      },
    }
};
</script>

<style>
</style>